public class Offer18 {
    public ListNode deleteNode(ListNode head, int val) {
        ListNode dummy = new ListNode(0, head);
        ListNode ret = dummy;
        while (dummy.next != null) {
            if (dummy.next.val == val) {
                dummy.next = dummy.next.next;
                return ret.next;//注意此处
            }
            dummy = dummy.next;
        }
        return ret.next;
    }
}
